
package com.yesep.learn.mqtt.client.handler.protocol;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.yesep.learn.mqtt.client.common.util.FixHeaderUtil;
import com.yesep.learn.mqtt.server.common.message.DupPubRelMessageStore;
import com.yesep.learn.mqtt.server.common.message.IDupPubRelMessageStoreService;
import com.yesep.learn.mqtt.server.common.message.IDupPublishMessageStoreService;

import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.mqtt.MqttFixedHeader;
import io.netty.handler.codec.mqtt.MqttMessage;
import io.netty.handler.codec.mqtt.MqttMessageFactory;
import io.netty.handler.codec.mqtt.MqttMessageIdVariableHeader;
import io.netty.handler.codec.mqtt.MqttMessageType;
import io.netty.handler.codec.mqtt.MqttPubAckMessage;
import io.netty.handler.codec.mqtt.MqttQoS;
import io.netty.util.AttributeKey;

/**
   * 消息编号：5
 * @Description: PUBREC连接处理，发布已接收，保证传递1
 */
public class PubRec {

	private static final Logger LOGGER = LoggerFactory.getLogger(PubRel.class);

	public void process(ChannelHandlerContext ctx, MqttMessage message) {
		MqttFixedHeader fixedHeader = FixHeaderUtil.from(MqttMessageType.PUBREL);
		MqttPubAckMessage pubRel = new MqttPubAckMessage(fixedHeader, (MqttMessageIdVariableHeader) message.variableHeader());
		ctx.channel().writeAndFlush(pubRel);
	}

}
